<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
   <div id="parent">
       <p id="child">hello world</p>
   </div>
   <button id="btn">btn</button>
    <script>
        /*
        语法 parentNode.replace(newNode,oldNode)
        */
     var btn=document.getElementById("btn");
     var parent=document.getElementById("parent");
     var child=document.getElementById("child");
     btn.onclick=function(){
         var h4=document.createElement("h4");
         var txt=document.createTextNode("修改");
         h4.appendChild(txt);

         parent.replaceChild(h4,child);
     }
    </script>
</body>
</html>